﻿/**
 * 
 * @file FITKAcousticsAbstractSpectra.h
 * @brief 频谱数据抽象类声明
 * @author LiBaojun (libaojunqd@foxmail.com)
 * @date 2024-10-21
 * 
 */
#ifndef _FITK_ACOUSTICS_ABSTRACT_SPECTRA_H___
#define _FITK_ACOUSTICS_ABSTRACT_SPECTRA_H___
 
#include "FITKAcousticsPhysicsAPI.h"
#include "FITKGlobalFrequencyDomain.h"
#include "FITK_Kernel/FITKCore/FITKAbstractNDataObject.h"
#include "FITK_Kernel/FITKCore/FITKNumberComplex.h"
#include <QList>

namespace Acoustics
{
    class FITKSpectraAlgorithm;
    class FITKGlobalFrequencyDomain;
    /**
     * @brief 频率信息
     * @author LiBaojun (libaojunqd@foxmail.com)
     * @date 2024-10-21
     */
    struct SpectraValue
    {
        double _hz{0};
        Core::FITKNumberComplex _value{0,0};
    };
    /**
     * @brief 频谱数据抽象对象
     * @author LiBaojun (libaojunqd@foxmail.com)
     * @date 2024-10-21
     */
    class FITKAcousticsPhysicsAPI FITKAcousticsAbstractSpectra :
        public Core::FITKAbstractNDataObject
    {
        Q_OBJECT
    public:
        /**
         * @brief 频谱类型
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-21
         */
        enum AcousticsSpectraType
        {
            None = -1,               ///< 无效类型
            Force = 2,               ///< 力
            Moment = 3,              ///< 力矩
            Pressure = 4,            ///< 声压
            Velocity = 5,            ///< 速度
            Energy = 8,              ///< 能量
            Damping = 9,             ///< 损耗因子谱
            TransmissionLoss = 10,   ///< 传递损失
            InsertionLoss = 11,      ///< 插入损失
            Absorption = 12,         ///< 吸声系数谱
            Coupling = 14,           ///< 耦合损耗因子谱
            Power = 23,              ///< 功率
            Acceleration = 24,       ///< 加速度
            AnlrVelocity = 25,       ///< 角速度
            Wavenumber = 29,         ///< 波数谱
            ModalDensity = 31,       ///< 模态密度
            ShearModulus = 39,       ///< 剪切模量
        };
        Q_ENUM(AcousticsSpectraType);
    public:
        /**
         * @brief Construct a new FITKAcousticsAbstractSpectra object
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-21
         */
        explicit FITKAcousticsAbstractSpectra();
        /**
         * @brief Destroy the FITKAcousticsAbstractSpectra object
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-21
         */
        virtual ~FITKAcousticsAbstractSpectra() = 0;
        /**
         * @brief 获取频谱类型
         * @return AcousticsSpectraType 
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-21
         */
        virtual AcousticsSpectraType getSpectraType() = 0;
        /**
         * @brief    获取频率类型
         * @return   FITKGlobalFrequencyDomain::DomainType  频率
         * @author   BaGuijun (baguijun@163.com)
         * @date     2024-10-31
         */
        FITKGlobalFrequencyDomain::DomainType getDomainType();

        /**
         * @brief    初始化(根据当前全局频率初始化)
         * @author   BaGuijun (baguijun@163.com)
         * @date     2024-11-01
         */
        virtual void init();
        /**
         * @brief    初始化(根据提供的参数进行初始化)
         * @param[i] startValue       频率初值
         * @param[i] endValue         频率末值
         * @param[i] type             频率类型
         * @param[i] octaveNum        Octave数量
         * @param[i] bandWidth        带宽
         * @author   BaGuijun (baguijun@163.com)
         * @date     2024-11-01
         */
        virtual void init(double startValue, double endValue, FITKGlobalFrequencyDomain::DomainType type);
        virtual void init(double startValue, double endValue, FITKGlobalFrequencyDomain::DomainType type, int octaveNum);
        virtual void init(double startValue, double endValue, FITKGlobalFrequencyDomain::DomainType type, double bandWidth);
        /**
         * @brief    拷贝函数
         * @param[i] copyData         数据对象
         * @author   BaGuijun (baguijun@163.com)
         * @date     2024-12-10
         */
        virtual void copy(FITKAcousticsAbstractSpectra* copyData);
        /**
         * @brief    获取频谱数据
         * @return   QList<SpectraValue>   全部数据
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-04
         */
        QList<SpectraValue> getSpectraValue();
        /**
         * @brief    设置频谱数据
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-04
         */
        void setSpectraValue(const QList<SpectraValue> spectraData);
        /**
         * @brief    获取开始频率
         * @return   double
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-04
         */
        double getStartFreq();
        /**
         * @brief    获取终止频率
         * @return   double
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-04
         */
        double getEndFreq();
        /**
         * @brief    获取频谱计算算法
         * @return   FITKSpectraAlgorithm *
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-04
         */
        FITKSpectraAlgorithm* getSpectraAlg();
        
        /**
         * @brief 设置频谱值
         * @param[i]  index         索引，超出索引不做操作
         * @param[i]  r             实部
         * @param[i]  i             虚部
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-21
         */
        void setSpectraValueAt(const int & index, const double & r = 1, const double & i = 0);
        /**
         * @brief 获取频谱数量
         * @return int 
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-21
         */
        int getSpectraCount();
        /**
         * @brief 获取频谱值
         * @param[i]  index          索引
         * @return SpectraValue 
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-21
         */
        SpectraValue getSpectraValueAt(const int index) const;
        /**
         * @brief 获取频谱值的实部值
         * @param[i]  index          索引
         * @return double
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-30
         */
        double getSpectraRealValue(const int index) const;
        /**
         * @brief 清理频谱值
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-21
         */
        virtual void clearSpectraValues();
        /**
         * @brief 重置频谱值
         * @param[i]  HzList         频率列表
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-21
         */
        virtual void resetSpectraValues(const QList<double>& HzList);
        /**
         * @brief 是否是实数
         * @return  bool     是否是实数
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-25
         */
        virtual bool isRealValue() = 0;
        /**
         * @brief    设置注释
         * @param[i] notes     注释
         * @author   BaGuijun (baguijun@163.com)
         * @date     2024-10-31
         */
        void setNotes(QString notes);
        /**
         * @brief    获取注释
         * @return   QString   注释
         * @author   BaGuijun (baguijun@163.com)
         * @date     2024-10-31
         */
        QString getNotes();
        /**
         * @brief    获取实际操作之后的频谱数据-纯虚
         * @return   QList<SpectraValue>
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-04
         */
        virtual QList<SpectraValue> getRealSpectraValue() = 0;
        /**
         * @brief    获取Octave数量
         * @return   int                Octave数量
         * @author   BaGuijun (baguijun@163.com)
         * @date     2024-12-13
         */
        int getOctaveNum();
        /**
         * @brief    获取带宽
         * @return   double             带宽
         * @author   BaGuijun (baguijun@163.com)
         * @date     2024-12-13
         */
        double getBandWidth();
    protected:
        /**
         * @brief    初始化数据
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-04
         */
        virtual void initData() = 0;

    protected:
        /**
         * @brief 频谱值列表
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-21
         */
        QList<SpectraValue> _spectraValues{};
        /**
         * @brief  频率类型
         * @author BaGuijun (baguijun@163.com)
         * @date   2024-10-31
         */
        FITKGlobalFrequencyDomain::DomainType _domainType = FITKGlobalFrequencyDomain::DomainType::DTNone;
        /**
         * @brief  注释
         * @author BaGuijun (baguijun@163.com)
         * @date   2024-10-31
         */
        QString _notes = "";
        /**
         * @brief  频谱算法数据
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-12-03
         */
        FITKSpectraAlgorithm* _spectraAlg{};
        /**
         * @brief    获取Octave数量
         * @return   int
         * @author   BaGuijun (baguijun@163.com)
         * @date     2024-12-13
         */
        int _octaveNum = 0;
        /**
         * @brief    获取带宽
         * @return   double
         * @author   BaGuijun (baguijun@163.com)
         * @date     2024-12-13
         */
        double _bandWidth = 0;
     };
}


#endif
